﻿using System.Diagnostics;

namespace 备忘录模式
{
    public class GameRole
    {
        //生命力
        public int Vitality { get; set; }
        //攻击力
        public int Attack { get; set; }
        //防御力
        public int Defense { get; set; }
        //状态显示
        public void StateDisplay()
        {
            Debug.WriteLine("角色当前状态：");
            Debug.WriteLine("体力：{0}", Vitality);
            Debug.WriteLine("攻击力：{0}", Attack);
            Debug.WriteLine("防御力：{0}", Defense);
        }
        //保存角色状态
        public RoleStateMemento SaveState()
        {
            return new RoleStateMemento(Vitality, Attack, Defense);
        }
        //恢复角色状态
        public void RecoveryState(RoleStateMemento memento)
        {
            Vitality = memento.Vitality;
            Attack = memento.Attack;
            Defense = memento.Defense;
        }
        //获得初始状态
        public void GetInitState()
        {
            Vitality = 100;
            Attack = 100;
            Defense = 100;
        }
        //战斗
        public void Fight()
        {
            Vitality = 50;
            Attack = 50;
            Defense = 50;
        }
    }
}
